<template>
  <div class="ad-list-item">
    <div class="item-content" :class="{'hot': data.charact_flag > 2}">
      <div class="item-image">
        <img :src="data.image"/>
      </div>
      <div class="item-text">
        <div class="item-title">{{data.title}}</div>
        <div class="item-hint">{{ascendancy}}</div>
      </div>
      <div v-if="false" class="flag" :class="{'hot': data.charact_flag === 2, 'new': data.charact_flag === 1}"></div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'ad-list-item',
  props: {
    data: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  computed: {
    ascendancy () {
      if (!this.data.desc || this.data.desc.length < 1) return
      return this.data.desc[0].content[0]
    }
  }
}
</script>
<style lang="scss" scoped>
@import '~@/scss/base.scss';
.ad-list-item{
  width: calc(50vw - 5px);
  margin-bottom: 3px;
  .item-content{
    margin: 5px;
    width: calc(50vw - 15px);
    height: 95px;
    background: url('~@/assets/img/list_item_new.png') no-repeat;
    background-size: calc(50vw - 15px) auto;
    border-radius: 5px;
    box-shadow: 0px 1px 5px rgba(0, 0, 0, .15);
    display: flex;
    align-items: center;
    position: relative;
    &.hot {
      background-image: url('~@/assets/img/list_item_hot.png');
    }
    .flag {
      position: absolute;
      top: -5px;
      right: 10px;
      &.hot {
        width: 17px;
        height: 20px;
        right: 15px;
        background: url('~@/assets/img/item_hot.png') no-repeat;
        background-size: 17px 20px;
      }
      &.new {
        width: 27px;
        height: 16px;
        background: url('~@/assets/img/item_new.png') no-repeat;
        background-size: 27px 16px;
      }
    }
    .item-image{
      flex-grow: 1;
      flex-basis: 0;
      flex-shrink: 0;
      display: flex;
      justify-content: center;
      img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
      }
    }
    .item-text{
      flex-grow: 2;
      flex-basis: 0;
      flex-shrink: 0;
      padding: 5px 10px 5px 5px;
      .item-title{
        font-size: 15px;
        margin-bottom: 5px;
        color: #333;
      }
      .item-hint{
        color: $hint-color;
        text-overflow: ellipsis;
        display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
        -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
        -webkit-line-clamp: 2; /** 显示的行数 **/
        overflow: hidden;  /** 隐藏超出的内容 **/
      }
    }
  }
}
</style>


